<?php

function oauthUserOption($current_openid = '')
{
    $users = db('oauth_users')->field(['nickname', 'openid', 'headimgurl'])->whereNotNull('nickname')->select();
    $html = '';
    if ($users) foreach ($users as $user) {
        $html .= sprintf('<option data-avatar="%s" value="%s" %s >%s(%s)</option>', $user['headimgurl'], $user['openid'], $user['openid'] == $current_openid ? 'selected' : '', $user['nickname'], $user['openid']);
    }
    return $html;
}
